Hi light,
I did not get properlly "Unless you are able to make use of the variable length array feature introduced in the 1999 edition of the C standard".
please can you tell once this?
Regards
NKRao
Printable View
I think we already have at least two or three times. The "variable length" feature in c99 -- the 1999 ANSI C standard -- allows you to declare an array with a variable length.
However, no C standard allows you to initialize such an object with values. You cannot do that, period, end of story.
Here are two declarations:
These variables have not been initialized; they could have any value in them.Code:int x;
int array[n];
Now x has been initialized. It could have been initialized in the declaration:Code:x = 12;
An array of fixed length can also be initialized in its declaration:Code:int x = 12;
However, you cannot:Code:int array[3] = {4, 5, 666};
1) initialize an array after its declaration; you must assign to individual elements.*
2) initialize a variable length array, such as "int array[n]"
Read posts #14 and #15 again if you still do not understand what this means. If you want to put values into a variable length array, you have to do so after the declaration.
* actually you can set more than one at time with memset().